﻿using iwintip.RssReader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.Entity;
using MvcPaging;

namespace iwintip.Controllers
{
    public class HomeController : Controller
    {
        private iwintipEntities db = new iwintipEntities();

        private IList<RECORD> allRecords = new List<RECORD>();
        private const int DefaultPageSize = 10;

        public ActionResult Index()
        {
            int nResultsInView = 10;
            NewsReader news = new NewsReader();
            List<FeedItem> result = news.GetRssByTag("http://www.baomoi.com/Home/TheThao/BongDa.rss", nResultsInView);

            return View(result);
        }

        public ActionResult About()
        {

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Rule()
        {

            return View();
        }

        public ActionResult Payment()
        {

            return View();
        }

        public ActionResult Record(int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;


            allRecords = db.RECORDs.Include(r => r.LEAGUE1).OrderByDescending(r => r.Time).ToList<RECORD>();

            return View(allRecords.ToPagedList(currentPageIndex, DefaultPageSize));
        }
    }
}
